package com.frxuexi.mdm2206.demo

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Demo05() {
    var isShow by remember {
        mutableStateOf(false)
    }

    Column {
        Button(onClick = {
            isShow=true
        }) {
            Text(text = "删除")
        }
    }

    if (isShow){
        /*AlertDialog(onDismissRequest = { isShow=false }, confirmButton = {
            Button(onClick = {
                isShow=false
            }) {
                Text(text = "确定")
            }
        }, dismissButton = {
            Button(onClick = { isShow=false }) {
                Text(text = "取消")
            }
        }, icon = { Icon(imageVector = Icons.Default.Delete, contentDescription = "")},
            title = { Text(text = "删除提醒")},
            text = { Text(text = "是否删除吗？")})*/
        AlertDialog(onDismissRequest = { isShow=false },
            modifier = Modifier
                .fillMaxWidth()
                .background(Color.White, RoundedCornerShape(20.dp))
                .padding(20.dp)) {
            Column {
                AsyncImage(model = "https://img1.baidu.com/it/u=4214113141,2036563917&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1731603600&t=4d6f50de01a6b2ba0cfad5e77060c1eb", contentDescription = "",
                    modifier = Modifier
                        .fillMaxWidth()
                        .height(200.dp), contentScale = ContentScale.Crop)
                Text(text = "这是以为美女")
                Row(Modifier.fillMaxWidth()) {
                    Button(onClick = { isShow=false }, Modifier.weight(1f)) {
                        Text(text = "取消")
                    }
                    Spacer(modifier = Modifier.width(20.dp))
                    Button(onClick = {
                        isShow=false
                    }, Modifier.weight(1f)) {
                        Text(text = "确定")
                    }
                }
            }
        }
    }
}